import random

from captcha.image import ImageCaptcha


def generate_captcha():
    text = ''.join([str(random.randint(0, 9)) for _ in range(4)])
    image = ImageCaptcha()
    data = image.generate(text)
    return text, data
